//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.example.service;

import cn.hutool.core.date.DateUtil;
import com.example.entity.Clubmember;
import com.example.entity.Club;
import com.example.mapper.ClubmemberMapper;
import com.example.service.ClubService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.Iterator;
import java.util.List;

@Service
public class ClubmemberService {
    @Resource
    private ClubmemberMapper clubmemberMapper;

    @Resource
    private ClubService clubService;

    public ClubmemberService() {
    }

    public void add(Clubmember clubmember) { //管理员不需要注册只需要新增，只有管理员才能增加管理员
        this.clubmemberMapper.insert(clubmember);
    }

    public void updateById(Clubmember clubmember) {
        this.clubmemberMapper.updateById(clubmember);
    }

    public void deleteById(Integer id) {
        this.clubmemberMapper.deleteById(id);
    }

    public void deleteBatch(List<Integer> ids) {
        Iterator var2 = ids.iterator();

        while(var2.hasNext()) {
            Integer id = (Integer)var2.next();
            this.deleteById(id);
        }

    }

    public Clubmember selectById(Integer id) {
        return this.clubmemberMapper.selectById(id);
    }
    public Clubmember selectBypresidentId(Integer presidentId) {
        return this.clubmemberMapper.selectBypresidentId(presidentId);
    }

    public List<Clubmember> selectAll(Clubmember clubmember) {
        return this.clubmemberMapper.selectAll(clubmember);
    }

    public List<Clubmember> selectList(Clubmember clubmember) {
        System.out.println(clubmember);
        return null;
    }

    /**
     * 分页查询社团成员
     * @param clubmember 查询条件（包含 clubName 和 studentName）
     * @param pageNum 页码
     * @param pageSize 每页数量
     * @param presidentId 当前社长ID
     * @return 分页结果
     */
    public PageInfo<Clubmember> selectPage(Clubmember clubmember, Integer pageNum, Integer pageSize, Integer presidentId) {
        PageHelper.startPage(pageNum, pageSize);
        
        // 直接使用传入的 presidentId 在Mapper层进行过滤
        List<Clubmember> list = this.clubmemberMapper.selectAll(clubmember);
        return PageInfo.of(list);
    }



}
